import 'package:flutter/material.dart';

class CustomStateLessWidget extends StatelessWidget {
  const CustomStateLessWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
            onPressed: () => {Navigator.pop(context)},
            icon: const Icon(Icons.arrow_back)),
        title: const Text('学习StateLessWidget'),
        centerTitle: true,
      ),
      body: CustomBodyWidget(),
    );
  }
}

class CustomBodyWidget extends StatelessWidget {
  CustomBodyWidget({super.key}) {
    print('CustomBodyWidget构造函数被创建');
  }

  @override
  Widget build(BuildContext context) {
    print('CustomBodyWidget构造函数被执行了');
    // 注意Container里面color和decoration不能一起存在
    return Container(
        width: 100,
        height: 100,
        // padding: const EdgeInsets.all(20), // 设置所有边的内边距
        // padding: const EdgeInsets.fromLTRB(20, 20, 20, 20) // 左上右下的内边距
        // margin: const EdgeInsets.all(10), // 外边距和内边距差不多
        decoration: BoxDecoration(
          border: Border.all(
              color: const Color.fromARGB(255, 118, 3, 250), width: 2),
          borderRadius: const BorderRadius.all(Radius.circular(10)),
          // 设置背景透明度相当于rgba
          color: const Color.fromARGB(255, 7, 248, 127),
          image: const DecorationImage(
              image: NetworkImage(
                  'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg'),
              fit: BoxFit.contain),
          // 阴影
          boxShadow: const [
            BoxShadow(
              color: Colors.black,
              offset: Offset(10, 10),
              blurRadius: 10,
            ),
          ],
        ),
        child: const Text('233232'));
  }
}
